/*
 * @Author: your name
 * @Date: 2021-08-28 16:16:47
 * @LastEditTime: 2021-08-29 17:04:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\7-数据类型转换.js
 */
//当两个都不是字符串类型，用xxx +'' + xxx 拼接
//当把一个不是字符串的转换成字符串类型的则是 xxx +''
//当一个不是字符串类型的和一个字符串类型的，则是 xxx+'xxx'
//当两个都是字符串类型的拼接在一起，则是 'xxx' +'' 'xxx'

//number转换字符串
console.log(123 + '' + 456); //'123456'
console.log(typeof(123 + '' + 456)); //String

//boolean类型转换
console.log(true + '' + 123); //'true123'
console.log(typeof(true + '' + 123)); //String


//null类型转换
console.log(null + ''); //'null'
console.log(typeof(null + '')); //String


//undefined转换字符串
console.log(undefined + ''); //'undefined'
console.log(typeof(undefined + '')); //String

//一个不是字符串类型和一个字符串类型
console.log(123 + 'hello'); //'123hello'
console.log(typeof(123 + 'hello')); //String

//转换成布尔类型
console.log(!!''); //false
console.log(!!' '); //true
console.log(!!'hello'); //true
console.log(!!123); //true

//转换成number类型
console.log(+'123'); //123
console.log(+true); //1
console.log(+false); //0
console.log(+null); //0
console.log(+undefined); //NAN